﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using DOAN.Public;

namespace DOAN.DLL
{
    public class ChiTietChiTruyCapDAL
    {
        ClsConnection cls;

        public ChiTietChiTruyCapDAL()
        {
            cls = new ClsConnection();
        }

        public DataTable Load()
        {
            return cls.GetData("CHITIETTRUYCAP_LOAD");
        }

        public int Insert(ChiTietTruyCapPublic p)
        {
            int Nparameter = 5;
            string[] name = new string[Nparameter];
            object[] value = new object[Nparameter];
            name[0] = "@MaChiTietTruyCap";
            name[1] = "@MaHopDong";
            name[2] = "@DiaChiTruyCap";
            name[3] = "@ThoiDiemTruyCap";
            name[4] = "@ChiTietTruyCap_Id";

            value[0] = p.MaChiTietTruyCap;
            value[1] = p.MaHopDong;
            value[2] = p.DiaChiTruyCap;
            value[3] = p.ThoiDiemTruyCap;
            value[4] = p.ChiTietTruyCap_Id;

            return cls.UpdateData("CHITIETTRUYCAP_INSERT", name, value, Nparameter);
        }

        public int Update(ChiTietTruyCapPublic p)
        {
            int Nparameter = 5;
            string[] name = new string[Nparameter];
            object[] value = new object[Nparameter];
            name[0] = "@MaChiTietTruyCap";
            name[1] = "@MaHopDong";
            name[2] = "@DiaChiTruyCap";
            name[3] = "@ThoiDiemTruyCap";
            name[4] = "@ChiTietTruyCap_Id";

            value[0] = p.MaChiTietTruyCap;
            value[1] = p.MaHopDong;
            value[2] = p.DiaChiTruyCap;
            value[3] = p.ThoiDiemTruyCap;
            value[4] = p.ChiTietTruyCap_Id;

            return cls.UpdateData("CHITIETTRUYCAP_UPDATE", name, value, Nparameter);
        }

        public int Delete(ChiTietTruyCapPublic p)
        {
            int Nparameter = 1;
            string[] name = new string[Nparameter];
            object[] value = new object[Nparameter];
            name[0] = "@MaChiTietTruyCap";
            value[0] = p.MaChiTietTruyCap;
            return cls.UpdateData("CHITIETTRUYCAP_DELETE", name, value, Nparameter);
        }
    }
}
